# -*- coding: utf-8 -*-

# File Name : __init__.py
# Description :
# Author : marje
# date : 2022/6/5
# Change Activity : 2022/6/5
from .img_transform import *
from .img_augment import *
from .bbox_transform import *
from ... import REGISTER_FACTORY

_REGISTRY_NAME = 'dl_modules'


def _build_registry():
    """
    build registry.

    """
    _register = REGISTER_FACTORY.create_registry(_REGISTRY_NAME)
    _register.add('ImageToTensor', value=ImageToTensor)
    _register.add('TensorToDevice', value=TensorToDevice)
    _register.add('ToDataType', value=ToDataType)
    _register.add('BoxXyxyToCxcywh', value=BoxXyxyToCxcywh)
    _register.add('RandomHorizontalFlip', value=RandomHorizontalFlip)
    _register.add('Normalize', value=Normalize)


_build_registry()  # build when module load.


def build_dl_modules(cfg=None, name=None):
    """
    build norm layer

    Args:
        name: module name
        cfg: must contain num_features;

    Returns:

    """
    return REGISTER_FACTORY.build_from_config(_REGISTRY_NAME, cfg, name)


def load_dl_module_registry():
    """
    init dl module.

    """
    return REGISTER_FACTORY.get_register(_REGISTRY_NAME)
